import { defineStore } from 'pinia'
import { ref } from 'vue'


export const useUserStore = defineStore('user', () => {
  const token = ref('')
  const setToken = (newToken) => {
    token.value = newToken
  }
  const userInfo = ref({})
  const setUserInfo = (newUserInfo) => {
    userInfo.value = newUserInfo
  }
  // 创建清空状态的方法
  const reset = () => {
    token.value = ''
    userInfo.value = {}
  };
  return {
    token,
    setToken,
    userInfo,
    setUserInfo,
    reset
  }
}, {
  persist: true
})